// src/api/task.js
import request from '@/utils/request';

export function createTask(taskData) {
  return request({
    url: '/api/tasks',
    method: 'post',
    data: taskData
  });
}

export function fetchTasks(query = {}) {
  return request({
    url: '/api/tasks',
    method: 'get',
    params: query // 将查询参数传递给后端
  });
}

export function updateTaskStatus(id, status) {
  return request({
    url: `/api/tasks/${id}/status?status=${encodeURIComponent(status)}`, // 如果后端API支持特定路径来更新状态
    method: 'put',
  });
}

export function deleteTask(id) {
  return request({
    url: `/api/tasks/${id}`,
    method: 'delete'
  });
}